#!/usr/bin/make -f

# force packages to be built with xz compression, as Ubuntu 21.10 and up use
# zstd compression, which is non-standard, and breaks 'dpkg-sig --verify'
override_dh_builddeb:
	dh_builddeb -- -Zxz

override_dh_auto_build:
	cd xray \
	&& GO111MODULE=on \
		env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w -buildid=" -o "xray" ./main

# http://manpages.debian.org/dh_dwz
override_dh_dwz:
	# dh_dwz in debhelper versions less than 13 has issues with files that are missing debug symbols (once we update to debhelper-compat 13+ this can be removed)
	@# https://packages.debian.org/debhelper
	@# https://packages.ubuntu.com/debhelper

override_dh_auto_install:
	install -D -m 0644 debian/config.json debian/xray/etc/xray/config.json
	install -D -m 0755 xray/xray debian/xray/usr/bin/xray
	install -D -m 0644 xray/geoip.dat debian/xray/usr/share/xray/geoip.dat
	install -D -m 0644 xray/geosite.dat debian/xray/usr/share/xray/geosite.dat

override_dh_installsystemd:
	dh_installsystemd --no-enable --no-start

override_dh_shlibdeps:
	dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info

%:
	dh $@